package com.bolt.report.business.test;

import com.bolt.convention.exception.ServiceException;
import com.bolt.support.codegenerator.db.AbstractTableFactory;
import com.bolt.support.codegenerator.db.TableFactory;
import com.bolt.support.codegenerator.model.Table;

import java.sql.SQLException;
import java.util.Map;

public class CodeGeneratorService {

    private TableFactory tableFactory ;


    public CodeGeneratorService(String url, String username, String password, String driverClass){
        tableFactory  = AbstractTableFactory.getInstance(url,username,password,driverClass);
    }


    public Map<String, String> getAllTables() {
        try {
            return tableFactory.getAllTables();
        } catch (Exception ex) {
            throw new ServiceException();
        }
    }


    public Table getTable(String tableName){
        try{
            return tableFactory.getTable(tableName);
        }catch (SQLException ex){
            throw new ServiceException();
        }
    }

}